<tagLib name="strends" />
<?php 
 function showWximg($ojb){
	return "<img src='".PIC_ROOT.$ojb."' width='50'>";
 }
 function usercount($ojb){
	$channelid = '1000000'.$ojb;
	$count = D("User")->where('channel_id='.$channelid)->count();
	return '<span style="background:#4d90fe;padding:15px 30px;cursor:pointer;" onclick="showuserlist('.$ojb.')">'.$count.'</span>';
 }
?>
<div id="showlist" style="display:none;float: left;position: fixed;z-index: 100000;top: 10px;left: 450px; background: #ddd;width: 200px;padding: 10px; line-height: 20px;">
	<div>
	<ul id="ul">
		
	</ul>
	</div>
	<input type="hidden" name="page" id="npage" value="0">
	<input type="hidden" name="page" id="allpage" value="0">
	<div style="background:#4d90fe;padding:5px 25px;;cursor:pointer;width:30px;margin-top:5px;" onclick="uhide()">关闭</div>
</div>
<include file="Public:header" />
<script type="text/javascript" src="__TMPL__Static/Js/dataList.js"></script>

<script>
	function showuserlist(ojb){
		$.ajax({
		  url: '/trends/index.php?m=WxChannel&a=showlist&tid='+ojb,
		  cache: false,
		  dataType:"json",
		  success:function(data)
		  {		
			var uhtml = '';
			for(var i=0;i<data.length;i++)
			{
			  uhtml += '<li><span>'+data[i]['day']+':</span><span style="padding-left:20px;">'+data[i]['ucount']+'人</span></li>';
			}
			uhtml +='<li><span onclick="showpre(1,'+ojb+')" style="cursor:pointer;">上一页</span>&nbsp;&nbsp;<span onclick="showpre(2,'+ojb+')" style="cursor:pointer;">下一页</span></li>';
			$('#showlist').show();
			$('#ul').empty();
			$('#ul').append(uhtml);
			$('#npage').val('0');
			$('#allpage').val(data[0]['allpage']);
		  }
		}); 
	}

	function uhide(){
		$('#showlist').hide();
	}
	function showpre(type,id){
		if(type==1){
			var p = $('#npage').val();
			var page = parseInt(p);
			if(page>0){
				$.ajax({
				  url: '/trends/index.php?m=WxChannel&a=showlist&tid='+id+'&type='+type+'&page='+page,
				  cache: false,
				  dataType:"json",
				  success:function(data)
				  {		
					var uhtml = '';
					for(var i=0;i<data.length;i++)
					{
					  uhtml += '<li><span>'+data[i]['day']+':</span><span style="padding-left:20px;">'+data[i]['ucount']+'人</span></li>';
					}
					uhtml +='<li><span onclick="showpre(1,'+id+')" style="cursor:pointer;">上一页</span>&nbsp;&nbsp;<span onclick="showpre(2,'+id+')" style="cursor:pointer;">下一页</span></li>';
					$('#showlist').show();
					$('#ul').empty();
					$('#ul').append(uhtml);
					var pre = page-1;
					$('#npage').val(pre);
				  }
				}); 
			}
		}else if(type==2){
			var p = $('#npage').val();
			var ap = $('#allpage').val();
			var page = parseInt(p);
			var allpage = parseInt(ap);
			if(page<allpage){
				$.ajax({
					  url: '/trends/index.php?m=WxChannel&a=showlist&tid='+id+'&type='+type+'&page='+page,
					  cache: false,
					  dataType:"json",
					  success:function(data)
					  {		
						var uhtml = '';
						for(var i=0;i<data.length;i++)
						{
						  uhtml += '<li><span>'+data[i]['day']+':</span><span style="padding-left:20px;">'+data[i]['ucount']+'人</span></li>';
						}
						uhtml +='<li><span onclick="showpre(1,'+id+')" style="cursor:pointer;">上一页</span>&nbsp;&nbsp;<span onclick="showpre(2,'+id+')" style="cursor:pointer;">下一页</span></li>';
						$('#showlist').show();
						$('#ul').empty();
						$('#ul').append(uhtml);
						var next = page+1;
						$('#npage').val(next);
					  }
				});
			}
			 
		}
	}
</script>
<div class="handle-btns">
	
</div>
<strends:list 
	id="checkList" 
	style="list" 
	name="cate" 
	checkbox="true" 
	action="true" 
	datasource="list" 
	show="id:{%ID}|80,title:{%TITLE}|~left,desc:{%DESC}|~left,best_img|showWximg:{%BEST_IMG}|~left,id|usercount:{%USER}|~left" 
	actionlist="downData:{%DOWNPIC}:id,editData:{%EDIT}:id" action_width="80" />
<div class="pager">{$page}</div>
<include file="Public:footer" />